﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Ext.Net;

public partial class SYS_POPEDOM_Sys_Param_Setting : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindGridData();
            //ShowFirstRowData("811","110");
        }
    }
    //绑定参数列表数据
    private void BindGridData()
    {
        DataTable dt = CommonLib.BLL.SYS_PARAMETER_VALUES.GetSysParameterList(BS_LoginDeptId.Trim(), "PARAMETER_ID").Tables[0];
        this.Store1.DataSource = dt;
        this.Store1.DataBind();
    }

    protected void OnGridRowSelect(object sender, DirectEventArgs e)
    {
        Ext.Net.Notification.Show(new NotificationConfig// Notification.Config
        {
            Title = "参数说明",
            IconCls = "",
            AutoHide = false,
            AlignCfg = new NotificationAlignConfig// Notification.AlignConfig
            {
                OffsetX = 10,
                OffsetY = 10,
                El = pnlNote.ClientID
            },
            Closable = false,
            BringToFront = true,
            Width = int.Parse(e.ExtraParams["ContainerWidth"]) + 10,
            Height = int.Parse(e.ExtraParams["ContainerHeight"]) + 10,
            BodyStyle = "font-size: 12;padding: 10px;",
            Html = e.ExtraParams["ParamNote"].ToString()
        });
        
        RowSelectionModel sm = this.GridPanel1.SelectionModel.Primary as RowSelectionModel;
        int a = sm.SelectedRows[0].RowIndex;
        string modify = "1";
        if (e.ExtraParams["ALLOWMODIFY"].ToString() == "是")
            modify = "0";
        pnlParam.LoadContent(G_Url_allstring + "/SYS_POPEDOM/Sys_Param_Value_Setting.aspx?PARAMETER_ID=" + e.ExtraParams["PARAMETER_ID"].ToString() + "&DEPT_ID=" + e.ExtraParams["DEPT_ID"].ToString() + "&ALLOWMODIFY=" + modify + "&PARAMETER_STR=" + e.ExtraParams["PARAMETER_STR"].ToString()+"&rowid="+a.ToString());
    }

    //解析选项字符串


    private string[] ParseSelectStr(string strSelect)
    {
        string[] stringSeparators = new string[] { "@" };

        string[] sArray = strSelect.Split(stringSeparators, StringSplitOptions.RemoveEmptyEntries);

        return sArray;

    }

    [DirectMethod]
    public void UpdateParmValue(string paramID, string paramDeptID, string paramValue)
    {
        CommonLib.Model.SYS_PARAMETER_VALUES oModel = new CommonLib.Model.SYS_PARAMETER_VALUES();
        oModel = CommonLib.BLL.SYS_PARAMETER_VALUES.GetModel(paramID,paramDeptID);
        oModel.PARAMETER_STR = paramValue;
        CommonLib.BLL.SYS_PARAMETER_VALUES.Update(oModel);
    }
}
